﻿// OutputPane.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "OutputPane.h"


// COutputPane

IMPLEMENT_DYNAMIC(COutputPane, CDockablePane)

COutputPane::COutputPane()
{

}

COutputPane::~COutputPane()
{
}


BEGIN_MESSAGE_MAP(COutputPane, CDockablePane)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_CONTEXTMENU()
END_MESSAGE_MAP()



// COutputPane 消息处理程序




int COutputPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDockablePane::OnCreate(lpCreateStruct) == -1)
		return -1;

	CRect rectDummy;
	rectDummy.SetRectEmpty();

	// 创建选项卡窗口: 
	if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1))
	{
		TRACE0("未能创建输出选项卡窗口\n");
		return -1;      // 未能创建
	}

	// 创建输出窗格: 
	const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;

	if (!m_wndOutputLog.Create(dwStyle, rectDummy, &m_wndTabs, 2))
	{
		TRACE0("未能创建日志输出窗口\n");
		return -1;      // 未能创建
	}

	if (!m_wndCheckResultList.Create(WS_CHILD, rectDummy, &m_wndTabs, 2))
	{
		TRACE0("未能创建检查结果输出窗口\n");
		return -1;      // 未能创建
	}


	CString strTabName;
	BOOL bNameValid;
	// 将列表窗口附加到选项卡: 
	bNameValid = strTabName.LoadString(IDS_LOG_TAB);
	m_wndTabs.AddTab(&m_wndOutputLog, strTabName, (UINT)0);
	bNameValid = strTabName.LoadString(IDS_TAB_CHECK_RESULT);
	m_wndTabs.AddTab(&m_wndCheckResultList, strTabName, (UINT)0);

	FillLogWindow();

	return 0;
}


void COutputPane::OnSize(UINT nType, int cx, int cy)
{
	CDockablePane::OnSize(nType, cx, cy);

	// TODO: 在此处添加消息处理程序代码
	m_wndTabs.SetWindowPos(nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
}


void COutputPane::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)
{
	// TODO: 在此处添加消息处理程序代码
}


void COutputPane::FillLogWindow()
{
	//m_wndOutputLog.AddString(_T("生成输出正显示在此处。"));
	//m_wndOutputLog.AddString(_T("输出正显示在列表视图的行中"));
	//m_wndOutputLog.AddString(_T("但您可以根据需要更改其显示方式..."));
}

void COutputPane::WriteLog(char* message)
{
	m_wndOutputLog.AddString(message);
	m_wndOutputLog.SetTopIndex(m_wndOutputLog.GetCount()-1);
}

void COutputPane::PopulateCheckResult(ck::check::CheckResultSet* pResultSet)
{
	m_wndCheckResultList.Populate(pResultSet);
}